package com.cw.base.jeeyc.biz.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cw.base.jeeyc.biz.converter.ApiDatabaseConverter;
import com.cw.base.jeeyc.biz.converter.SysExceptionTradeConverter;
import com.cw.base.jeeyc.biz.intf.SysExceptionTradeQueryBiz;
import com.cw.base.jeeyc.dao.mapper.SysExceptionTradeMapper;
import com.cw.base.jeeyc.dao.model.SysExceptionTradeDo;
import com.cw.base.jeeyc.sys.dto.SysExceptionTradeDto;

/**
 * 异常登记接口业务实现类
 *
 * @author admin
 * @date 2020-08-02 12:07:20
 */
@Service
public class SysExceptionTradeQueryBizImpl extends ServiceImpl<SysExceptionTradeMapper, SysExceptionTradeDo>
    implements SysExceptionTradeQueryBiz {
    @Autowired
    private SysExceptionTradeMapper sysExceptionTradeMapper;

    /**
     * 分页查询异常登记
     *
     * @param request 条件
     * @return PageInfo<SysExceptionTradeDto>
     */
    @Override
    public Page<SysExceptionTradeDto> selectPage(SysExceptionTradeDto request) {
        Page page = getBaseMapper().selectPage(new Page<>(request.getPageNum(), request.getPageSize()),
            SysExceptionTradeConverter.buildWrapper(request));
        page.setRecords(ApiDatabaseConverter.doList2DtoList(page.getRecords()));
        return page;
    }

    /**
     * 查询异常登记详情信息
     *
     * @param request 条件
     * @return SysExceptionTradeDto
     */
    @Override
    public SysExceptionTradeDto queryDetail(SysExceptionTradeDto request) {
        if (request == null) {
            return null;
        }
        return SysExceptionTradeConverter.do2Dto(sysExceptionTradeMapper.selectById(request.getId()));
    }

    /**
     * 根据条件查询异常登记
     *
     * @param request 条件
     * @return List<SysExceptionTradeDto>
     */
    @Override
    public List<SysExceptionTradeDto> queryList(SysExceptionTradeDto request) {
        if (request == null) {
            return null;
        }
        return SysExceptionTradeConverter.doList2DtoList(
            sysExceptionTradeMapper.selectList(SysExceptionTradeConverter.buildWrapper(request)));
    }

    /**
     * 根据key查询异常登记
     *
     * @param id
     * @return
     */
    @Override
    public SysExceptionTradeDto selectByKey(Long id) {

        return SysExceptionTradeConverter.do2Dto(sysExceptionTradeMapper.selectById(id));
    }
}
